home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cxl400.arc / CXLKEY.H < prev    next >
C/C++ Source or Header  |  1988-11-19  |  4KB  |  94 lines

  1.  
  2. /*
  3.    ┌──────────────────────────────────────────────────────────────────────────┐
  4.    │                                                                          │
  5.    │  CXLKEY.H - CXL (c) 1987, 1988 by Mike Smedley.                          │
  6.    │                                                                          │
  7.    │  This header file contains function prototypes and definitions for       │
  8.    │  keyboard functions.  Keyboard functions for windowing functions are     │
  9.    │  defined in CXLWIN.H                                                     │
  10.    │                                                                          │
  11.    └──────────────────────────────────────────────────────────────────────────┘
  12. */
  13.  
  14.  
  15. #if defined(__TURBOC__)
  16.     #if __STDC__
  17.         #define _Cdecl
  18.     #else
  19.         #define _Cdecl  cdecl
  20.     #endif
  21.     #define _Near
  22. #elif defined(__ZTC__)
  23.     #define _Cdecl
  24.     #define _Near
  25. #elif defined(M_I86) && !defined(__ZTC__)
  26.     #if !defined(NO_EXT_KEYS)
  27.         #define _Cdecl  cdecl
  28.         #define _Near   near
  29.     #else
  30.         #define _Cdecl
  31.         #define _Near
  32.     #endif
  33. #endif
  34.  
  35.  
  36. /*---------------------------[ Function Prototypes ]-------------------------*/
  37.  
  38. int      _Cdecl getchf(char *valid,int defchar);
  39. int      _Cdecl getns(char *str,int max);
  40. unsigned _Cdecl getxch(void);
  41. int      _Cdecl inputsf(char *str,char *fmt);
  42. int      _Cdecl setonkey(unsigned keycode,void (*func) (void),int pass);
  43. int      _Cdecl waitkey(void);
  44. int      _Cdecl waitkeyt(int duration);
  45.  
  46.  
  47. /*-----------------------[ definition of onkey record ]----------------------*/
  48.  
  49. struct _onkey_t {
  50.     struct _onkey_t *prev;              /* pointer to previous record       */
  51.     struct _onkey_t *next;              /* pointer to next record           */
  52.     unsigned int keycode;               /* Scan/ASCII code of trap key      */
  53.     void (*func) (void);                /* address of onkey function        */
  54.     int pass;                           /* pass key to caller? 0=no, 1=yes  */
  55. };
  56.                                         /* pointer to current onkey record  */
  57. extern struct _onkey_t *_Near _Cdecl _onkey;        
  58.  
  59.                                         /* pointer to procedure to call
  60.                                            while waiting for keypress   */
  61. extern void (*_Near _Cdecl _kbloop) (void);
  62.  
  63. /*-------------[ keyboard status codes returned from kbstat() ]--------------*/
  64.  
  65. #define RSHIFT      1                   /*  right shift pressed          */
  66. #define LSHIFT      2                   /*  left shift pressed           */
  67. #define CTRL        4                   /*  <Ctrl> pressed               */
  68. #define ALT         8                   /*  <Alt> pressed                */
  69. #define SCRLOCK     16                  /*  <Scroll Lock> toggled        */
  70. #define NUMLOCK     32                  /*  <Num Lock> toggled           */
  71. #define CAPSLOCK    64                  /*  <Caps Lock> toggled          */
  72. #define INS         128                 /*  <Ins> toggled                */
  73.  
  74.  
  75. /*-----------------------[ macro-function definitions ]-----------------------*/
  76.  
  77. #if !defined(MK_FP)
  78. #define MK_FP(seg,ofs)      ((void far *) (((unsigned long)(seg) << 16) | \
  79.                             (unsigned)(ofs)))
  80. #endif
  81. #if !defined(poke)
  82. #define poke(a,b,c)         (*((int  far*)MK_FP((a),(b))) = (int)(c))
  83. #define pokeb(a,b,c)        (*((char far*)MK_FP((a),(b))) = (char)(c))
  84. #define peek(a,b)           (*((int  far*)MK_FP((a),(b))))
  85. #define peekb(a,b)          (*((char far*)MK_FP((a),(b))))
  86. #endif
  87. #define capsoff()           poke(0,0x417,peek(0,0x417)&191)
  88. #define capson()            poke(0,0x417,peek(0,0x417)|64)
  89. #define clearkeys()         while(kbhit()) getch()
  90. #define kbstat()            peek(0,0x417)
  91. #define numoff()            poke(0,0x417,peek(0,0x417)&223)
  92. #define numon()             poke(0,0x417,peek(0,0x417)|32)
  93. #define setkbloop(a)        (_kbloop=a)
  94.